// ==UserScript== // @name Platform Spoofer // @namespace https://viayoo.com/ // @version 0.6 // @description Modify platform Only. // @author Via // @match *://*/* // @exclude *://rebang.today/* // @exclude *://*.github.com/* // @exclude *://scriptcat.org/* // @exclude *://greasyfork.org/* // @exclude *://github.com/* // @exclude *://*.google.*/* // @exclude *://x.com/* // @exclude *://twitter.com/* // @exclude *://*.bing.*/* // @exclude *://*.baidu.*/* // @exclude *://*.yandex.*/* // @exclude *://*.iqiyi.com/* // @exclude *://*.qq.com/* // @exclude *://*.v.qq.com/* // @exclude *://*.sohu.com/* // @exclude *://*.mgtv.com/* // @exclude *://*.ifeng.com/* // @exclude *://*.pptv.com/* // @exclude *://*.sina.com.cn/* // @license MIT // @grant none // @run-at document-start // ==/UserScript== (function() { 'use strict'; const FAKE_PLATFORM = 'Mac'; const BYPASS_PLATFORM = 'iPhone'; const FAKE_USER_AGENT = 'Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.0 Mobile/15E148 Safari/604.1'; const log = (message) => console.log(`[Platform Spoofer] ${message}`); function applyPlatformSpoof() { if (navigator.platform === FAKE_PLATFORM) return; let detectionMode = false; const platformGetter = () => detectionMode ? BYPASS_PLATFORM : FAKE_PLATFORM; try { const descriptor = Object.getOwnPropertyDescriptor(navigator, 'platform'); if (descriptor?.configurable) { Object.defineProperty(navigator, 'platform', { get: platformGetter, configurable: true, enumerable: true }); } else if (navigator.__defineGetter__) { navigator.__defineGetter__('platform', platformGetter); } const originalIndexOf = String.prototype.indexOf; const originalToString = String.prototype.toString; const spoofNavigator = new Proxy(navigator, { get: (target, prop) => { if (prop === 'platform') return platformGetter(); if (prop === 'userAgent') return FAKE_USER_AGENT; const value = Reflect.get(target, prop); return typeof value === 'function' ? value.bind(target) : value; } }); Object.defineProperty(window, 'navigator', { value: spoofNavigator, writable: false, configurable: true }); Object.freeze(window.navigator); String.prototype.indexOf = function(searchString) { const self = String(this); if (self === FAKE_PLATFORM || self === BYPASS_PLATFORM) { detectionMode = true; if (searchString === 'Win' || searchString === 'Mac') return -1; if (searchString === 'Linux' || searchString === 'X11') return -1; detectionMode = false; } return originalIndexOf.call(this, searchString); }; String.prototype.toString = function() { return this === navigator.platform ? platformGetter() : originalToString.call(this); }; } catch (e) { console.warn('[Platform Spoofer] Spoofing error:', e); window.navigator = new Proxy(navigator, { get: (target, prop) => { if (prop === 'platform') return FAKE_PLATFORM; if (prop === 'userAgent') return FAKE_USER_AGENT; return Reflect.get(target, prop); } }); } } applyPlatformSpoof(); if (document.readyState === 'loading' && navigator.platform !== FAKE_PLATFORM) { document.addEventListener('DOMContentLoaded', applyPlatformSpoof, { once: true }); } })();